export type RepositoryApi = {
    name: string;
    private: boolean;
    owner: {
        login: string;
        avatar_url: string;
        html_url: string;
        type: string;
    };
    html_url: string;
    description: string | null;
    fork: boolean;
    forks_url: string;
    languages_url: string;
    stargazers_url: string;
    contributors_url: string;
    created_at: string;
    updated_at: string;
    pushed_at: string;
    homepage: string;
    stargazers_count: number;
    watchers_count: number;
    language: string | null;
    forks_count: number;
    archived: boolean;
    disabled: boolean;
    topics: string[];
};

export type RepositoryModel = {
    name: string;
    private: boolean;
    owner: {
        login: string;
        avatarUrl: string;
        htmlUrl: string;
        type: string;
    };
    htmlUrl: string;
    description: string | null;
    fork: boolean;
    forksUrl: string;
    languagesUrl: string;
    stargazersUrl: string;
    contributorsUrl: string;
    createdAt: string;
    updatedAt: string;
    pushedAt: string;
    homepage: string;
    stargazersCount: number;
    watchersCount: number;
    language: string | null;
    forksCount: number;
    archived: boolean;
    disabled: boolean;
    topics: string[];
};

export const normalizeRepository = (from: RepositoryApi): RepositoryModel => ({
    ...from,
    owner: {
        ...from.owner,
        avatarUrl: from.owner.avatar_url,
        htmlUrl: from.owner.html_url,
    },
    htmlUrl: from.html_url,
    forksUrl: from.forks_url,
    languagesUrl: from.languages_url,
    stargazersUrl: from.stargazers_url,
    contributorsUrl: from.contributors_url,
    createdAt: from.created_at,
    updatedAt: from.updated_at,
    pushedAt: from.pushed_at,
    stargazersCount: from.stargazers_count,
    watchersCount: from.watchers_count,
    forksCount: from.forks_count,
});
